package org.nowcoder.huawei.c200;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 10:城市聚集度
 */
public class HC010 {

    // 递归深度优先搜索遍历：当前城市连接的城市数
    public static int dfs(int city, List<List<Integer>> adjList, boolean[] visited) {
        visited[city] = true;
        int count = 1;
        for (int neighbor : adjList.get(city)) {
            if (!visited[neighbor]) {
                count += dfs(neighbor, adjList, visited);
            }
        }
        return count;
    }

    // 寻找DP值最小的城市
    public static List<Integer> findMinDPCity(int n, List<int[]> connections) {
        // 创建邻接表表示城市连接关系
        List<List<Integer>> adjList = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            adjList.add(new ArrayList<>());
        }

        // 构建邻接表
        for (int[] connection : connections) {
            int x = connection[0];
            int y = connection[1];
            adjList.get(x).add(y);
            adjList.get(y).add(x);
        }

        int minDP = Integer.MAX_VALUE; // 最小的DP值
        List<Integer> dpValues = new ArrayList<>(); // 存储所有城市的DP值

        // 遍历每个城市
        for (int city = 1; city <= n; city++) {
            boolean[] visited = new boolean[n + 1];
            visited[city] = true;
            int DP = 0;

            // 遍历与当前城市相邻的城市
            for (int neighbor : adjList.get(city)) {
                if (!visited[neighbor]) {
                    int count = dfs(neighbor, adjList, visited);
                    DP = Math.max(DP, count);
                }
            }

            dpValues.add(DP);
            minDP = Math.min(minDP, DP);
        }

        List<Integer> result = new ArrayList<>();
        // 找到具有最小DP值的城市
        for (int i = 0; i < dpValues.size(); i++) {
            if (dpValues.get(i) == minDP) {
                result.add(i + 1);
            }
        }

        return result;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<int[]> connections = new ArrayList<>();
        // 读取城市连接关系
        for (int i = 0; i < n - 1; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            connections.add(new int[]{x, y});
        }
        scanner.close();

        // 寻找DP值最小的城市
        List<Integer> minDPCities = findMinDPCity(n, connections);

        // 输出结果
        for (int city : minDPCities) {
            System.out.println(city);
        }
    }
}
